from rest_framework.generics import ListAPIView
from rest_framework.permissions import IsAdminUser

from goods.models import SPU, SPUSpecification
from meiduo_admin.serializer.spus import SPUSimpleSerializer, SPUSpecSerializer


class SPUSimpleView(ListAPIView):
    permission_classes = [IsAdminUser]
    queryset = SPU.objects.all()
    serializer_class = SPUSimpleSerializer
    pagination_class = None


class SPUSpecView(ListAPIView):
    permission_classes = [IsAdminUser]
    def get_queryset(self):
        pk = self.kwargs['pk']
        value = SPUSpecification.objects.filter(spu_id=pk)
        return value

    serializer_class = SPUSpecSerializer

    pagination_class = None





